From: Fredrik Eriksson Date: Sat, 28 Dec 2024 11:34:12 +0000 (+0100) Subject: Fix .netrc parsing X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~157^2~2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=38f1d05636c18385a02360dd47785cc1e92b6c41;p=nextcloud-desktop.git Fix .netrc parsing Fixes: #7177 Signed-off-by: Fredrik Eriksson --- diff --git a/src/cmd/netrcparser.cpp b/src/cmd/netrcparser.cpp index 266fe4f3e..15417e134 100644 --- a/src/cmd/netrcparser.cpp +++ b/src/cmd/netrcparser.cpp @@ -14,8 +14,7 @@ #include #include -#include -#include +#include #include @@ -58,32 +57,33 @@ bool NetrcParser::parse() } QString content = netrc.readAll(); - auto tokenizer = QStringTokenizer{content, u" \n\t"}; + auto tokens = content.split(QRegularExpression("\\s+")); LoginPair pair; QString machine; bool isDefault = false; - for(auto itToken = tokenizer.cbegin(); itToken != tokenizer.cend(); ++itToken) { - const auto key = *itToken; + for(int i=0; i tokens.count()) { qDebug() << "error fetching value for" << key; return false; } - auto value = *(++itToken); + auto value = tokens[i]; if (key == machineKeyword) { tryAddEntryAndClear(machine, pair, isDefault); - machine = value.toString(); + machine = value; } else if (key == loginKeyword) { - pair.first = value.toString(); + pair.first = value; } else if (key == passwordKeyword) { - pair.second = value.toString(); + pair.second = value; } // ignore unsupported tokens } tryAddEntryAndClear(machine, pair, isDefault);